import { defineStore} from "pinia";
import {reactive, ref} from "vue";
import {getUserInfo} from "../api/user.ts";

export const  userStore =defineStore({
    id : "userStore",
    state: () =>({
        userinfo : ref(null)
    }),
    actions:{
        async setInfo(){
            this.userinfo = (await getUserInfo()).data.data;
            console.log("userinfo",this.userinfo)
            return this.userinfo
        }
    },
    persist: {
        key: 'userStore',
        storage: localStorage,
        paths: ["userinfo"],
    },
})